package com.github.scr.hashmap;

import com.github.scr.hashmap.maps.IndexedMap;
import com.unbiz.common.collection.IntHashMap;
import com.unbiz.common.collection.StringHashMap;
import com.unbiz.common.test.SizeOfObject;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * Created by scr on 7/3/15.
 */
public class WriterMain {   
    
    public void testWrite() throws IOException {
        @SuppressWarnings("unchecked")
        IndexedMap<CharSequence, Integer> map = (IndexedMap<CharSequence, Integer>) DataHelper.simple().next()[1];
        map.writePath(Paths.get("map.bin"));
    }
    
    
    public static void main(String[] args) throws IOException, IllegalAccessException {
    	//Map<Integer, Integer> intMap = new ConcurrentSkipListMap<>();
    	/**
    	Map<String, Integer> intMap = new HashMap<>();
    	int count = 50000000; //一亿
    	for(int i=0;i<count;i++){
    		Integer key = Integer.valueOf(i);
    		intMap.put(key.toString(), i);    		
    	}
    	*/
    	/**
    	IntHashMap<Integer> intMap = new IntHashMap<>();
    	int count = 100000000; //一亿
    	for(int i=0;i<count;i++){
    		Integer key = Integer.valueOf(i);
    		intMap.put(i, i);    		
    	}
    	*/
    	
    	StringHashMap<Integer> intMap = new StringHashMap<>();
    	int count = 50000000; //一亿
    	for(int i=0;i<count;i++){
    		Integer key = Integer.valueOf(i);
    		intMap.putIndex(key.toString(), i);    		
    	}
    	
    	long size = SizeOfObject.sizeOf(intMap);
    	//size = SizeOfObject.deepSizeOf(intMap);
    	System.out.println("size of "+ "obj" +" = "+size);
    	System.in.read();
    }
}
